package com.aididi.mapper;

import com.aididi.entity.BrokerMessageLog;
import com.aididi.entity.BrokerMessageLogExample;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface BrokerMessageLogMapper {
    int countByExample(BrokerMessageLogExample example);

    int deleteByExample(BrokerMessageLogExample example);

    int deleteByPrimaryKey(String messageId);

    int insert(BrokerMessageLog record);

    int insertSelective(BrokerMessageLog record);

    List<BrokerMessageLog> selectByExample(BrokerMessageLogExample example);

    BrokerMessageLog selectByPrimaryKey(String messageId);

    int updateByExampleSelective(@Param("record") BrokerMessageLog record, @Param("example") BrokerMessageLogExample example);

    int updateByExample(@Param("record") BrokerMessageLog record, @Param("example") BrokerMessageLogExample example);

    int updateByPrimaryKeySelective(BrokerMessageLog record);

    int updateByPrimaryKey(BrokerMessageLog record);

    /**
     * @Description: 查询消息状态为0（发送中），且已经超时的消息集合
     * @Author zx.xu
     * @Param: []
     */
    List<BrokerMessageLog> queryStatusAndTimeOutMessage();

    /**
     * 重新投递，统计count发送次数+1
     * @param messageId
     * @param update
     */
    void updateAndSend(@Param("messageId")String messageId,@Param("update") Date update);

    /**
     * 更新最终消息发送结果 成功or失败
     * @param messageId
     * @param status
     * @param updateTime
     */
    void changeBrokerMessageLogStatus(@Param("messageId") String messageId,
                                      @Param("status") String status,
                                      @Param("updateTime") Date updateTime);
}